class swarmProc : public IPCObject {
	public:

	swarmBin * sb;

	swarmProc( swarmBin * sb ) {
		this->sb = sb;
	}

	virtual void run() {
		bool action;

		while ( ! this->sb->binIsComplete() ) {
			action = false;

			this->sb->resetNodes();
//			this->sb->diagDump();

			for ( int ix = 0; ix < this->sb->getX(); ++ix ) {
				for ( int iy = 0; iy < this->sb->getY(); ++iy ) {
					node * n = this->sb->getNode( ix, iy );
					if ( n->evaluate() ) {
						action = true;
					}
				}
			}
			if ( action == false && ! this->sb->binIsComplete() ) {
				this->sb->deNodeLockGrid();
			}
		}
		std::cout << "Complete\n";
	}

};

void * thread_swarmProc( void * ptr ) {
	swarmProc * sp = static_cast <swarmProc *> (ptr);
	sp->run();
	void * ret = NULL;
	return ret;
}

